import 'package:courseapp/entity/TeacherSignDTO.dart' as TeacherSignDTO;
import 'package:courseapp/http/HttpUtils.dart';
import 'package:flutter/material.dart';

import 'StudentSignRecord.dart';

class TeacherSignRecord extends StatefulWidget {





  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return TeacherSignState();
  }


}


class TeacherSignState extends State {



  static int courseId;
  List<TeacherSignDTO.DataBean> _list = [];

  @override
  void initState()  {
    initRequest();
  }
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(appBar: AppBar(leading: FlatButton(child:Icon(Icons.arrow_back,color: Colors.white,),onPressed: (){Navigator.of(context).pop();},),title: Text("老师签到记录"),),
      body: ListView.builder(
          itemCount: _list.length,
          itemBuilder: _buildItem),
    );
  }


  Widget _buildItem(BuildContext context, int index) {
    TeacherSignDTO.DataBean dataBean = _list[index];
    var signNum = dataBean.signNum;
    var notSignNum = dataBean.notSignNum;
    var totalSignNum = dataBean.totalSignNum;
    var signDate = dataBean.signDate;
    return  FlatButton(
        onPressed: (){
          StudentSignState.teacherSignId = dataBean.teacherSignId;
          Navigator.of(context).push(new MaterialPageRoute(builder: (context){ return StudentSignRecord(); }));
        },
        color: Colors.white,
        padding: EdgeInsets.all(0),
        child: DecoratedBox(
            decoration: BoxDecoration( color: Colors.white, border: Border(bottom: Divider.createBorderSide(context, color: Colors.grey),)),
            child:Container(padding: EdgeInsets.all(5) ,child: Column(children: <Widget>[
              Container(alignment: Alignment.centerLeft, child:Text("签到人数 :$signNum",style: TextStyle(color: Colors.black),)),
              Container(alignment: Alignment.centerLeft, child:Text("未签到数 :$notSignNum",style: TextStyle(color: Colors.black),)),
              Container(alignment: Alignment.centerLeft, child:Text("总签到数 :$totalSignNum",style: TextStyle(color: Colors.black),)),
              Container(alignment: Alignment.centerLeft, child:Text("签到时间 :$signDate",style: TextStyle(color: Colors.black),)),
              ],)))
    );
  }

  void initRequest() async {
    TeacherSignDTO.TeacherSignDTO signRecordDTO = await HttpUtil.getInstance().queryTeacherSign(courseId);
    _list.addAll(signRecordDTO.data);
    setState(() {});
  }


}
